import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/device/lock/widgets/operation_record/list_item.dart";
import "package:ct_pa_majordomo/pages/device/widgets/device_header.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";

class OperationRecord extends StatefulWidget {
  const OperationRecord({super.key});

  @override
  State<StatefulWidget> createState() => _OperationRecordState();

}

class _OperationRecordState extends State<OperationRecord> {

  List _list = ["", ""];

  @override
  Widget build(BuildContext context) {
    return DeviceHeader(
        title: "操作记录",
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios_new),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        showSearch: false,
        showFloatBtn: false,
        actions: [
          TextButton(
            onPressed: () {},
            child: const Text("读取记录", style: TextStyle(color: Colors.white),)
          ),
        ],
        children: [
          Positioned(
            width: MediaQuery.of(context).size.width,
            top: 0,
            left: 0,
            child: Container(
              width: MediaQuery.of(context).size.width,
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
              padding: const EdgeInsets.symmetric(horizontal: ThemeVars.paddingPage, vertical: 6),
              child: const SizedBox(
                height: 40,
                child: TextField(
                  decoration: InputDecoration(
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                      borderSide: BorderSide.none
                    ),
                    hintText: "请搜索",
                    isDense: true,
                    filled: true,
                    fillColor: ThemeVars.colorBackground,
                    suffixIcon: SizedBox(
                      child: Icon(Icons.search, size: 20,),
                    ),
                  ),
                  style: TextStyle(fontSize: 14),
                ),
              )
            )
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            margin: const EdgeInsets.only(top: 60, left: ThemeVars.paddingPage, right: ThemeVars.paddingPage),
            child: ListView(
              children: List.generate(_list.length * 2 - 1, (index) {
                if (index.isOdd) {
                  return const SizedBox(height: 12,);
                }
                return const ListItem();
              }),
            ),
          ),
        ]
    );
  }

}